<template>
  <base-breadcrumb>
    <div v-loading="loading">
      <a-card :bordered="false">
        <title-name title="基础信息" />

        <a-row :gutter="24">
          <a-col span="8">
            <a-form-item
              label="项目名称"
              :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
              :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
            >
              <BaseInput v-model=" projectName" disabled />
            </a-form-item>
          </a-col>
          <a-col span="8">
            <a-form-item
              label="分包商名称"
              :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
              :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
            >
              <BaseInput v-model="subcontractorName" disabled />
            </a-form-item>
          </a-col>
          <a-col span="8">
            <a-form-item
              label="考核时间"
              :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
              :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
            >
              <a-month-picker
                v-model="dels.assessmentTime"
                placeholder=""
                style="width: 100%;"
                @change="assessmentTimes"
              />
            </a-form-item>
          </a-col>
          <a-col span="8">
            <a-form-item
              label="考核总分"
              :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
              :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
            >
              <BaseInput v-model="dels.serviceScoreDTO.totalScore" disabled />
            </a-form-item>
          </a-col>
          <a-col span="8" v-if="dels.serviceScoreDTO.fileInfoVO.length">
            <a-form-item
              label="佐证附件"
              :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
              :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
            >
              <BUploadVModel v-model="dels.serviceScoreDTO.fileInfoVO" uploadType="single" businessCode="LCM08"
                             :need-chinese-name="true"
                             disabled=""
              />
            </a-form-item>
          </a-col>
          <a-col span="8">
            <a-form-item
              label="考核等级"
              :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
              :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
            >
              <BaseInput v-model="dels.assessmentLevel" disabled />
            </a-form-item>
          </a-col>
          <a-col span="8">
            <a-form-item
              label="实际考核人"
              :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
              :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
            >
              <BaseInput v-model="dels.serviceScoreDTO.actualUserName" disabled />
            </a-form-item>
          </a-col>
        </a-row>
      </a-card>

      <div style="float: right;margin-top: 20px" class="page-btn-right-top">
        <a-button type="primary" @click="$close">关闭</a-button>
      </div>
    </div>
  </base-breadcrumb>
</template>

<script>
import { Ellipsis } from '@/components'
import { getMonthContent } from '@/api/subcontractors/monthAssessment'
import printButton from '@/components/BasePrintButton'
import ARow from 'ant-design-vue/es/grid/Row'
import Vue from 'vue'
import BUploadVModel from '@/components/BComponents/BUploadVModel'

export default {
  name: 'a' + Date.now(),
  components: {
    ARow,
    printButton,
    Ellipsis,
    BUploadVModel
  },
  data() {
    return {
      loading: false,
      dels: { serviceScoreDTO: { fileInfoVO: [], totalScore: '' } },
      token: '',
      projectName: this.$route.query.projectName,
      subcontractorName: this.$route.query.subcontractorName,
    }
  },
  created() {
    this.token = Vue.getAcloudProvider().getAccessToken()
    this.assessmentId = this.$route.query.assessmentId
    this.getMonthContent()
  },
  methods: {
    async getMonthContent(data = { id: this.assessmentId }) {
      this.loading = true
      let res = await getMonthContent(data)
      this.loading = false
      if (res.code === 200) {
        this.dels = { ...this.dels, ...res.data }
        if (!this.dels.serviceScoreDTO) {
          this.dels.serviceScoreDTO = { fileInfoVO: [], totalScore: '' }
        }
        if (!this.dels.serviceScoreDTO.fileInfoVO) {
          this.dels.serviceScoreDTO.fileInfoVO = []
        }
      }
    },
    // 格式化时间
    async assessmentTimes(val) {
      this.dels.assessmentTime = val.format('YYYY-MM')
      let data = { subcontractorId: this.dels.subcontractorId, assessmentTime: this.dels.assessmentTime }
      await this.getMonthContent(data)
    }
  }
}
</script>
<style scoped>
.notScore {
  width: 65px;
  display: flex
}
</style>

